using JGSY.CMS.LowCode.Platform.Domain.Interfaces;

namespace JGSY.CMS.LowCode.Platform.Domain.Entities.Monitoring;

/// <summary>
/// 监控性能指标实体
/// 存储 Core Web Vitals 和自定义性能指标
/// </summary>
public class MonitorPerformanceMetric : ITenantEntity
{
    /// <summary>
    /// 主键ID
    /// </summary>
    public long Id { get; set; }

    /// <summary>
    /// 会话ID - 用于关联同一用户会话的多个指标
    /// </summary>
    public string SessionId { get; set; } = string.Empty;

    /// <summary>
    /// 用户ID - 可选，用于用户维度的性能分析
    /// </summary>
    public string? UserId { get; set; }

    /// <summary>
    /// 指标名称 - LCP, FID, CLS, FCP, TTFB, CustomMetric
    /// </summary>
    public string MetricName { get; set; } = string.Empty;

    /// <summary>
    /// 指标数值 - 毫秒或无单位数值
    /// </summary>
    public decimal MetricValue { get; set; }

    /// <summary>
    /// 指标评级 - good, needs-improvement, poor
    /// </summary>
    public string? MetricRating { get; set; }

    /// <summary>
    /// 页面URL - 指标采集时的页面地址
    /// </summary>
    public string PageUrl { get; set; } = string.Empty;

    /// <summary>
    /// 用户代理字符串
    /// </summary>
    public string? UserAgent { get; set; }

    /// <summary>
    /// 浏览器名称 - Chrome, Firefox, Safari, Edge
    /// </summary>
    public string? BrowserName { get; set; }

    /// <summary>
    /// 设备类型 - desktop, mobile, tablet
    /// </summary>
    public string? DeviceType { get; set; }

    /// <summary>
    /// 时间戳 - JavaScript Date.now() 毫秒时间戳
    /// </summary>
    public long Timestamp { get; set; }

    /// <summary>
    /// 创建时间 - 数据库记录创建时间
    /// </summary>
    public DateTime CreatedAt { get; set; } = DateTime.UtcNow;

    /// <summary>
    /// 租户标识符
    /// </summary>
    public string TenantId { get; set; } = string.Empty;
}
